package com.stenio.fancat;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.stenio.fancat.common.constants.GlobalConstant;
import com.stenio.fancat.util.SmsUtil;

@Configuration
@MapperScan("com.stenio.fancat.**.mapper")
public class ApplicationContext {

	/**
	 * mybatis-plus分页插件
	 */
	@Bean
	public PaginationInterceptor paginationInterceptor() {
		PaginationInterceptor page = new PaginationInterceptor();
		page.setDialectType(GlobalConstant.DB_DIALECT_TYPE);
		return page;
	}

	/**
	 * 乐观锁 插件
	 * 
	 * @return
	 */
	@Bean
	public OptimisticLockerInterceptor optimisticLoker() {
		return new OptimisticLockerInterceptor();
	}

	@Bean
	public SmsUtil getSmsUtil() {
		return new SmsUtil();
	}

}
